/** \file
 *	\brief
 *
 *	
 */

#ifndef OMD_LAYOUT_INCLUDED
#define OMD_LAYOUT_INCLUDED

#include "../mds/frame.h"
#include "../ocl/queue.h"

/** \brief manage ocl_buffers for mds_frame 
 */
typedef struct 
{
	size_t      num_particles; /*!< number of particles              */
	size_t      num_buffers;   /*!< enough for the algorithms        */
	ocl_buffer *buffers;       /*!< OpenCL buffers                   */
	size_t      reserved;      /*!< for memory management            */
}
omd_layout;

#define OMD_LAYOUT_INIT { 0, 0, NULL, 0 }

/** \brief Create requested OpenCL buffers.
 *	
 */
int  omd_layout_load(omd_layout *layout,
					 ocl_context *context, 
					 size_t       num_particles,
					 size_t       num_buffers);

/** \brief Clean up.
 *
 */
void omd_layout_quit( omd_layout *layout );

/**	\brief Write frame->sets[field] to layout->buffers[field].
 */
int  omd_layout_write( omd_layout *layout, ocl_queue *Q, mds_frame *frame, size_t field, cl_bool blocking );

/**	\brief Read frame->sets[field] from layout->buffers[field].
 */
int  omd_layout_read( omd_layout *layout, ocl_queue *Q, mds_frame *frame, size_t field, cl_bool blocking );

#endif
